home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4013 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.0 KB

  1. Path: news1.h1.usa.pipeline.com!usenet
  2. From: grantp@usa.pipeline.com
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: while (fgets(element,30,fileptr) != "*")
  5. Date: 26 Jan 1996 22:48:42 GMT
  6. Organization: Kalevi, Inc.
  7. Message-ID: <4ebloa$k6d@news1.usa.pipeline.com>
  8. NNTP-Posting-Host: pipe12.h1.usa.pipeline.com
  9. X-PipeUser: grantp
  10. X-PipeHub: usa.pipeline.com
  11. X-PipeGCOS: (Pete)
  12. X-Newsreader: Pipeline USA v3.3.0
  13.  
  14. On Jan 26, 1996 15:52:30 in article <while (fgets(element,30,fileptr) !=
  15. "*")>, 'wharris@mail.utexas.edu (W.  Harris)' wrote: 
  16.  
  17.  
  18. >Could someone tell me why this doesn't work? I've tried "*/0",  
  19. >"*//0","*/0/r", etc. 
  20.  
  21. Because you're comparing pointers to strings rather than 
  22. the strings themselves. 
  23.  
  24. try: 
  25.  
  26. If your intent is to test only whether or not the first character 
  27. is an asterisk, ignoring the rest: 
  28. while(fgets(element, 30, fileptr) && (element[0] != '*')) 
  29.  
  30. if you want to test for a string of exactly "*", use 
  31. while(fgets(element, 30, fileptr) && strcmp(element, "*")) 
  32.  
  33. -- 
  34. Pete Grant 
  35. Kalevi, Inc. 
  36. Object Oriented Software Development
  37.